#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll t, n, m, L, V;
ll d[100005], v[100005], a[100005], p[100005];
vector<pair<ll, ll> >step2;
ll ans1, ans2;
void fun(ll tmp, ll st, ll ed){
    ans1++;
    step2.push_back(make_pair(lower_bound(p + 1, p + m + 1, st) - p, upper_bound(p + 1, p + m + 1, ed) - p - 1));
    //cout << st << ' ' << ed << endl;
}
int main(){
    freopen("detect.in", "r", stdin);
    freopen("detect.out", "w", stdout);
    cin >> t;
    while(t--){
        cin >> n >> m >> L >> V;
        ans1 = 0;
        ans2 = m;
        step2.clear();
        for(ll i = 1; i <= n; i++){
            cin >> d[i] >> v[i] >> a[i];
        }ll tmp;
        for(ll i = 1; i <= m; i++){
            cin >> p[i];
        }for(ll i = 1; i <= n; i++){
            if(a[i] == 0){
                if(v[i] > V && p[m] >= d[i])    fun(i, d[i], p[m]);
            }else if(a[i] < 0 && v[i] > V){
                ll dis = ceil((double)(V * V - v[i] * v[i]) / (double)(2 * a[i])) + d[i];
                dis = min(dis, L) + 1;
                if(*lower_bound(p + 1, p + m + 1, d[i]) < dis)    fun(i, d[i], dis - 1);
            }else if(a[i] > 0){
                if(v[i] > V && p[m] >= d[i])    fun(i, d[i], p[m]);
                else{
                    ll dis = (V * V - v[i] * v[i]) / (2 * a[i]) + d[i];
                    dis = min(dis, L);
                    if(p[m] > dis)  fun(i, dis + 1, m);
                }
            }
        }
        ll j;
        bool ok;
        for(ll i = 0; i < step2.size();){
            ok = 0;
            for(j = i + 1; j < step2.size() && step2[j].first < step2[i].second; j++){
                if(step2[j].second <= step2[i].second)  {ok = 1;break;}
            }i = j;
            if(ok == 0) ans2--;
        }
        cout << ans1 << ' ' << ans2 << endl;
    }return 0;
}
